package com.colorsstudio.defence.Levels
{
	import com.colorsstudio.defence.ConstantValues.Constants;
	import flash.display.Sprite;
	import idv.cjcat.fenofsm.events.StateEvent;
	import idv.cjcat.fenofsm.Transition;
	
	import com.greensock.*;
	import com.greensock.easing.*;
	
	/**
	 * ...
	 * @author wuzhida
	 */
	public class levelLogo extends Level
	{
		public var t_Pre_Logo:Transition;
		public var logo:Sprite;
		
		public function levelLogo()
		{
			super();
		}
		
		override public function setState():void
		{			
			state = Constants.fsm.createState("levelLogo");
			t_Pre_Logo = Constants.fsm.createTransition(Constants.fsm.getStateByName("prepareBeforeGame"), state, "toLogo", "t_Pre_Logo", 0);
			super.setState();
		}
		
		override public function levelStart(e:StateEvent):void
		{
			super.levelStart(e);
			trace("Now the Logo Screen is enter!");			
			Constants.main.addChild(this);			
			logo = new f_logo();
			logo.x = Constants.SCREEN_WIDTH / 2;
			logo.y = Constants.SCREEN_HEIGHT / 2;
			this.layer1.addChild(logo);
			TweenLite.to(logo, 2, {x:logo.x, y:logo.y, alpha:0, ease:Back.easeIn,onComplete:toEnd});		
		}		
		
		private function toEnd():void 
		{
			Constants.fsm.input("toStartScreen");
		}
		
		override public function levelEnd(e:StateEvent):void 
		{
			super.levelEnd(e);					
			Constants.main.removeChild(this);		
		}
	}
}